package com.xiaomengkuan.product.controller;

import com.xiaomengkuan.common.util.DetailSelector;
import com.xiaomengkuan.common.util.R;
import com.xiaomengkuan.product.entity.pojo.Tag;
import com.xiaomengkuan.product.service.TagService;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author Faraj Mujey
 * -- Creation Time: 2021-01-26 7:32 下午, File Encoding: utf8 --
 */
@Api(tags = "查询标签")
@RestController
@RequestMapping("product/tag")
public class TagController {
    @Resource
    private TagService tagService;

    /**
     * 根据类型（type）查询tag
     * @param type 类型
     * @return R
     */
    @GetMapping("/type/{type}")
    public R getByType(@PathVariable("type") int type) {
        List<Tag> tags
                = tagService.getByType(type);
        return R.ok().detail(DetailSelector.QUERY_SUCCESS).putList(tags);
    }
}
